package com.bigcat.gulimall.demo.test;

import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;

import java.util.ArrayList;

/**
 * @Athor:Yuan
 * @Date:2020/9/22 16:55
 * Desc:
 *
 * 源码：为其绝对值的二进制展开后的高位补1
 * 反码：为其源码除符号位外其余全取反
 * 补码：为其源码除符号位外全部取反然后地位补0
 */
public class test1 {
    public static void main(String[] args) {
        User demo1 = new User("demo1", 29, 170);
        User demo2 = new User("demo2", 21, 175);
        User demo3 = new User("demo3", 25, 180);
        User user = new User() {

            @Override
            public Integer getAge() {
                System.out.println("123123123");
                return 1123123;
            }
        };

        Integer age = user.getAge();
        ArrayList<User> userArrayList = Lists.newArrayList(demo1, demo2, demo3);
        double average = userArrayList.stream().mapToDouble(User::getAge).average().orElse(0.00);
        System.out.println(JSON.toJSONString(average));
    }
}
